package com.vote.service;

import java.sql.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.vote.entity.Channel;
import com.vote.entity.Ip;
import com.vote.entity.Vote;
import com.vote.entity.VoteOption;
import com.vote.mapper.ChannelMapper;

@Service
public class ChannelServiceImpl implements ChannelService {

	@Autowired
	ChannelMapper channelMapper;
	
	
	public List<Channel> getAllChannel() {
		List<Channel> allChannel = channelMapper.getAllChannel();
		return allChannel;
	}
	
	
	public List<Vote> getVoteList(int channelId) {
		List<Vote> voteList = channelMapper.getVoteList(channelId);
		return voteList;
	}
	
	
	public List<VoteOption> getvoteOptionList(int voteId) {
		List<VoteOption> voteOptionList = channelMapper.getvoteOptionList(voteId);
		return voteOptionList;
	}
	
	
	public VoteOption getvoteOption(int oid) {
		VoteOption voteOption = channelMapper.getvoteOption(oid);
		return voteOption;
	}
	
	
	public int updateVoteOption(VoteOption voteOption) {
		int result=0;
		result = channelMapper.updateVoteOption(voteOption);
		return result;
	}
	
	
	public int addOption(VoteOption option) {
		int add = channelMapper.addOption(option);
		return add;
	}
	
	
	public int getMaxSqeNumber(int voteId) {
		int maxSeqNumber = channelMapper.getMaxSqeNumber(voteId);
		return maxSeqNumber;
	}
	
	
	
	public VoteOption getAddVoteOption(String addvalue, int voteId) {
		VoteOption voteOption = channelMapper.getAddVoteOption(addvalue,voteId);
		return voteOption;
	}
	
	
	public int addIp(Ip ip) {
		int addip = channelMapper.addIp(ip);
		return addip;
	}
	
	
	public Ip getIP(String ip, Date date, int channelId) {
		Ip ipBean = channelMapper.getIp(ip,date,channelId);
		return ipBean;
	}

}
